<template>
  <div class="search">
    <f-drawer ref="bmpDetailsDrawer" width="90%" @submit="handleSubmit" @visibleChange="visibleChange" :showFooter="false">
      <a-tabs @tabClick="tabClick" :defaultActiveKey="current" v-model="current">
        <a-tab-pane tab="详情列表" key="details_list">
          <bmp-details-list ref="details_list" v-if="drawerVisible" :detailsParams="detailsParams"></bmp-details-list>
        </a-tab-pane>
      </a-tabs>
    </f-drawer>
  </div>
</template>
<script>
  import bmpDetailsList from './bmp_details_list.vue'

  export default {
    name: 'bmpDetailsDrawer',
    components: { bmpDetailsList },
    props: {},
    data() {
      return {
        refs: this.$refs,
        drawerVisible: false,
        isEdit: false,
        title: '',
        current: 'details_list',
        formData: {},
        forms: [
          'details_list'
        ],
        detailsParams: {}
      }
    },
    methods: {
      showDrawer(data) {
        this.isEdit = false
        if (data && data.materialPackage100Id) {
          this.isEdit = true
          this.formData = data
        } else {
          this.formData = {}
        }
        this.detailsParams.projectId = data.projectId
        this.detailsParams.packageNo = data.packageNo
        this.detailsParams.majorCode = data.majorCode
        this.detailsParams.materialId = data.materialId
        this.detailsParams.isGroup = false
        this.refs['bmpDetailsDrawer'].show()
        this.tabClick('details_list')
      },
      handleSubmit(callback) {
        this.refs[this.current].handleSubmit(callback)
      },
      visibleChange(drawerVisible) {
        this.drawerVisible = drawerVisible
      },
      tabClick(name) {
        this.current = name
        if (this.current === 'details_list') {
          this.title = '详情列表'
        }
      }
    },
    computed: {
      drawerTitle: function() {
        return this.title
      }
    },
    created() {
    }
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
